# -*- coding: utf-8 -*-
# @project: huawang-api20230914
# @file： yk_names.py
# @Time：2023/8/10 16:15
# @Author：liaogan
from selenium.webdriver.common.by import By

"""公共部分"""
class Pubelement:
    # 搜索按钮
    el_icon_search = lambda: (By.XPATH, "//span[contains(text(),'搜索')]")
    # 重置按钮
    el_resetting_button = lambda: (By.XPATH, "//span[contains(text(),'重置')]")
    # 商品新增按钮
    el_Product_add = lambda: (By.XPATH, "//button[@type='button']//span[contains(text(),'新增')]")
    # 修改按钮
    el_edit_button = lambda: (By.XPATH, "//span[contains(text(),'修改')]")
    # 删除按钮
    el_delete_button = lambda: (By.XPATH, "//span[contains(text(),'删除')]")
    # 导出按钮
    el_export_button = lambda: (By.XPATH, "//span[contains(text(),'导出')]")
    # 刷新
    el_confirm_button = lambda: (By.CSS_SELECTOR, "//span[contains(text(),'刷新')]")
    # 保存
    el_sava_buttom = lambda: (By.XPATH, "//span[contains(text(),'保存')]")
    # tips
    el_tips = lambda: (By.XPATH, "//p[@class='el-message__content']")


class mainPage:
    # 首页
    home_button = lambda: (By.XPATH, "//li[@role='menuitem']//span[contains(text(),'首页')]")
    # 终端装修
    Terminal_decoration = lambda: (By.XPATH, "//span[contains(text(),'终端装修')]")
    submenu_shop_decoration = lambda: (By.XPATH, "//span[contains(text(),'商城装修')]")

    # 商品管理
    menu_productmanage = lambda: (By.XPATH, "//div[@class='el-submenu__title']//span[contains(text(),'商品管理')]")
    menu_productmanage1=lambda:(By.XPATH,'//div[@class="menu-wrapper"][3]/li')
    submenu_productlist = lambda: (By.XPATH, "//span[contains(text(),'商品分类')]")
    submenu_menuproduct = lambda: (By.XPATH, "//li[@role='menuitem']//span[contains(text(),'管理商品')]")
    submenu_productnuit = lambda: (By.XPATH, "//span[contains(text(),'商品规格')]")
    submenu_Freight_template = lambda: (By.XPATH, "//span[contains(text(),'运费模版')]")
    submenu_Browsing_history = lambda: (By.XPATH, "//span[contains(text(),'浏览记录')]")
    submenu_productCollect = lambda: (By.XPATH, "//span[contains(text(),'商品收藏')]")

    menu_member = lambda: (By.XPATH, "//span[contains(text(),'会员管理')]")
    submenu_memberlist = lambda: (By.XPATH, "//span[contains(text(),'会员列表')]")
    submenu_grade = lambda: (By.XPATH, "//span[contains(text(),'会员等级')]")
    submenu_Applet_Configuration = lambda: (By.XPATH, "//span[contains(text(),'小程序配置')]")

    menu_order = lambda: (By.XPATH, "//span[contains(text(),'订单管理')]")
    submenu_order = lambda: (By.XPATH, "//span[contains(text(),'订单')]")
    submenu_evaluation_management = lambda: (By.XPATH, "//span[contains(text(),'评价管理')]")
    submenu_logistics_managment = lambda: (By.XPATH, "//span[contains(text(),'物流管理')]")
    submenu_AfterSales = lambda: (By.XPATH, "//span[contains(text(),'售后')]")

    menu_coupon = lambda: (By.XPATH, "//span[contains(text(),'电子券管理')]")
    menu_coupon1= lambda:(By.XPATH,'//div[@class="menu-wrapper"][6]/li')
    submenu_newcoupon = lambda: (By.XPATH, "//span[contains(text(),'优惠券制作')]")
    submenu_publish_coupon = lambda: (By.XPATH, "//span[contains(text(),'已发布优惠券')]")
    submenu_Coupon_collection_record = lambda: (By.XPATH, "//span[contains(text(),'优惠券领取记录')]")

    menu_finance_management = lambda: (By.XPATH, "//span[contains(text(),'财务管理')]")
    submenu_Withdrawal_management = lambda: (By.XPATH, "//span[contains(text(),'提现管理')]")
    submenu_Billing_audit = lambda: (By.XPATH, "//span[contains(text(),'开票审核')]")
    submenu_Broad_bean_detail = lambda: (By.XPATH, "//span[contains(text(),'花豆明细')]")
    submenu_fund_water = lambda: (By.XPATH, "//span[contains(text(),'资金流水')]")
    submenu_bonus_management = lambda: (By.XPATH, "//span[contains(text(),'奖金管理')]")
    submenu_Retail_revenue = lambda: (By.XPATH, "//span[contains(text(),'零售收入')]")
    submenu_Billing_record = lambda: (By.XPATH, "//span[contains(text(),'开票记录')]")
    submenu_tree = lambda: (By.XPATH, "//span[contains(text(),'关系树')]")
    submenu_Retail_revenue_Broad_bean = lambda: (By.XPATH, "//span[contains(text(),'零售收入充花豆')]")
    submenu_coin_Broad_bean = lambda: (By.XPATH, "//span[contains(text(),'花币充花豆')]")

    menu_store = lambda: (By.XPATH, "//span[contains(text(),'门店管理')]")
    submenu_storelist = lambda: (By.XPATH, "//span[contains(text(),'门店列表')]")
    submenu_verification_order = lambda: (By.XPATH, "//span[contains(text(),'核销订单')]")
    submenu_Store_audit = lambda: (By.XPATH, "//span[contains(text(),'门店审核')]")


class Product_search:
    """商品搜索"""
    # 商品搜索框
    el_input_goods = lambda: (By.XPATH, "//div[@id='pane-first']//input[@placeholder='输入搜索内容']")
    #待上架商品搜索框
    el_dwon_InoutGoods=lambda :(By.XPATH,"//div[@id='pane-second']//input[contains(@placeholder,'输入搜索内容')]")
    # 搜索类型
    el_Search_tpye = lambda: (By.XPATH, "//input[contains(@placeholder,'搜索类型')]")
    # 选择下拉菜单里面的商品名称
    el_dowm_goods_name = lambda: (By.CSS_SELECTOR, "div[x-placement='bottom-start'] span")
    # 点击商品搜索
    el_button_search = lambda: (By.XPATH, "//div[@id='pane-first']//span[contains(text(),'搜索')]")
    # 搜索1条记录
    el_1_result = lambda: (By.XPATH, "//div[contains(text(),'轻澜牌低聚肽藤茶饮品 25ML/瓶10瓶/盒')]")
    # 获取搜索到的第一个商品
    el_up_first_product = lambda: (By.CSS_SELECTOR,
                            'body > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > section:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(3) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3) > div:nth-child(1)')
    #出售中的商品
    el_Pending_Product = lambda:(By.XPATH,"//div[@id='tab-first']")
    # 搜索上架第一页所有商品
    el_up_allproduct = lambda: (By.XPATH, '//div[@class="el-table__body-wrapper is-scrolling-none"]//td[3]')
    #未上架搜索类型
    el_down_Search_product=lambda :(By.XPATH,"//div[@id='pane-second']//div[@class='head-container']//div[2]//div[1]//span[1]//span[1]//i[1]")
    #选择商品名称
    el_down_ProductName=lambda: (By.CSS_SELECTOR, "div[x-placement='bottom-start'] span")
    #点击搜素
    el_dwon_Search=lambda :(By.XPATH,"//div[@id='pane-second']//span[contains(text(),'搜索')]")

    #搜索商品结果
    el_Product_Results=lambda :(By.XPATH,"")


class Spel:
    """添加商品页操作"""
    # """(//i[@class='el-select__caret el-input__icon el-icon-arrow-up'])[1]"""
    el_button_product_select=lambda:(By.XPATH,"(//i[@class='el-select__caret el-input__icon el-icon-arrow-up'])[1]")#选择商品类型下拉框
    el_product_1=lambda :(By.CSS_SELECTOR," //span[contains(text(),'普通商品')]")#点击普通商品
    el_product_2 = lambda: (By.CSS_SELECTOR, "//span[contains(text(),'普通商品')]")#会员礼包
    el_product_3 = lambda: (By.CSS_SELECTOR, "//span[contains(text(),'普通商品')]")#云客礼包
    el_input_product_name = lambda: (By.XPATH,"//input[@placeholder='请输入商品名称']")  # 输入商品名称框
    el_product_type_button = lambda: (By.XPATH, "(//input[@placeholder='请选择'])[2]")  # 选择商品分类
    el_product_type_name = lambda: (By.XPATH, "//div[@x-placement='bottom-start']//li[2]")  # 选择分类为酱酒
    el_product_keyword = lambda: (By.XPATH, '//input[@placeholder="请输入商品关键字"]')  # 输入商品关键字
    el_product_unit = lambda: (By.XPATH, "//input[@placeholder='请输入单位']")  # 输入单位为：瓶
    el_product_introduction = lambda: (By.XPATH, "//textarea[@placeholder='请输入商品简介']")  # 输入商品 简介
    el_tax_code_button = lambda: (By.XPATH, "(//input[@placeholder='请选择'])[3]")  # 点击税收编码
    el_tax_code_select = lambda: (By.XPATH, "//li[contains(text(),'1030306-果酒/米酒')]")  # 选择果酒

    """商品封面图"""
    el_product_Background = lambda: (
    By.XPATH, "//label[contains(text(),'商品封面图：')]/..//*[@class='el-icon-plus']")  # 点击商品封面图
    el_product_frist = lambda: (
    By.XPATH, "//div[@aria-label='checkbox-group']//div[1]//div[1]//div[1]//div[2]//label[1]//span[1]//span[1]")
    el_button_Background = lambda: (By.XPATH, "(//span[contains(text(),'确 定')])[3]")  # 图片素材库点击确认

    """商品轮播图"""
    el_product_banner = lambda: (
    By.XPATH, "//label[contains(text(),'商品轮播图：')]/..//*[@class='el-icon-plus']")  # 点击商品轮播图
    el_banner_product_frist = lambda: (By.XPATH,
                                       "//body/div[5]/div/div[2]/section/main/div/div[2]/div/div[1]/div/div[1]/div/div/div[2]/label/span[1]/span")
    el_banner_button_Background = lambda: (By.XPATH, "(//span[contains(text(),'确 定')])[3]")  # 图片素材库点击确认

    """商品规格"""
    el_product_specifications1 = lambda: (By.XPATH, "(//span[@class='el-radio__inner'])[1]")  # 点击单规格
    el_product_specifications2 = lambda: (By.XPATH, "(//span[@class='el-radio__inner'])[2]")  # 点击多规格
    el_input_sale = lambda: (By.XPATH, "(//input[contains(@type,'number')])[1]")  # 输入售价
    el_input_costprice = lambda: (By.XPATH, "(//input[contains(@type,'number')])[2]")  # 成本价
    el_input_originalprice = lambda: (By.XPATH, "(//input[contains(@type,'number')])[3]")  # 原价
    el_input_invent = lambda: (By.XPATH, "(//input[contains(@type,'number')])[4]")  # 库存
    el_input_num = lambda: (By.XPATH, "(//input[contains(@type,'number')])[5]")  # 数量
    el_input_productnum = lambda: (By.XPATH, "(//input[contains(@type,'text')])[7]")  # 商品编码
    el_input_weight = lambda: (By.XPATH, "(//input[contains(@type,'number')])[6]")  # 重量
    el_input_volume = lambda: (By.XPATH, "(//input[contains(@type,'number')])[7]")  # 体积

    """运费模版"""
    el_button_Freight_template = lambda: (By.XPATH, "(//input[contains(@placeholder,'请选择')])[4]")  # 点击运费模版
    el_select_Freight_template = lambda: (By.XPATH, "//span[contains(text(),'包邮')]")  # 选择包邮
    el_input_product_details = lambda: (By.XPATH, "//div[@class='ql-editor ql-blank']")  # 输入商品详情内容
    el_input_virtuallysale = lambda: (By.XPATH, '//input[@placeholder="请输入虚拟销量"]')  # 虚拟销量
    el_input_sort = lambda: (By.XPATH, '//input[@placeholder="请输入排序"]')  # 排序
    el_delist = lambda: (
    By.XPATH, "//div[@class='el-row']//div[4]//div[1]//div[1]//div[1]//label[2]//span[1]//span[1]")  # 商品下架
    el_button_sava = lambda: (By.XPATH, "//span[contains(text(),'保存')]")  # 点击保存
    el_down_product = lambda: (By.XPATH, "//div[@id='tab-second']")  # 点击待上架商品

    """获取商品管理第一个商品名称"""
    el_up_first_product = lambda: (By.CSS_SELECTOR,
                                   'body > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > section:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(3) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3) > div:nth-child(1)')
    el_down_first_product = lambda: (By.CSS_SELECTOR,
                                     'body > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > section:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(3) > table:nth-child(1) > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3) > div:nth-child(1)')

    """删除商品操作"""
    el_search_product = lambda: (By.XPATH, "//div[@id='pane-second']//span[contains(text(),'搜索')]")
    # 点击删除第一个商品操作
    el_delete_down_first_product = lambda: (By.XPATH, "//tbody/tr[1]/td[9]/div[1]/span[1]/span[1]/button[1]")
    # 点击确认
    el_first1_button = lambda: (By.XPATH, "(//span[contains(text(),'确定')])[20]")
    # 点击确认
    el_frist_button=lambda:(By.XPATH,"(//span[contains(text(),'确定')])[11]")
    # 删除成功tip提示
    el_delete_uess = lambda: (By.XPATH, '//h2[@class="el-notification__title"]')


class addCoponPage:
    """新增电子优惠券"""
    # 点击新增
    el_add_button = lambda: (By.XPATH, "//button[@type='button']//span[contains(text(),'新增')]")
    # 通用券
    el_public_copon = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[1]//label[1]/span/span')
    # 商品券
    el_product_copon = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[1]//label[2]/span/span')
    # 优惠券用途1通用  2平台那个单使用  3线下订单使用
    el_copon_1 = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[2]//label[1]')
    el_copon_2 = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[2]//label[2]')
    el_copon_3 = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[2]//label[3]')
    # 点击优惠券选择框
    el_product_selectomania = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[3]//i[@class="el-icon-plus"]')
    # 选择第一个商品
    el_second_proudct = lambda: (By.XPATH, '(//tbody//span[@class="el-checkbox__inner"])[2]')
    # 确认选择
    el_verify_selector = lambda: (By.XPATH, "//span[contains(text(),'确定选择')]")
    # 输入优惠券名称
    el_input_coponname = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[4]//input')
    # 优惠券面值
    el_input_coponsal_facevalue = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[5]//input')
    # 优惠券最低消费
    el_input_copon_minimumcharge = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[6]//input')
    # 优惠券有效期限(天)
    el_input_coponsal_validity = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[7]//input')
    # 排序
    el_sort = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[8]//input')
    # 状态 1为开启， 0为关闭
    el_status = lambda: (By.XPATH, '(//div[@class="el-form-item__content"])[9]//input[@value="1"]')
    # 点击确认
    el_all_verify1=lambda :(By.XPATH,"//div[2]/div/div[3]/div/button[2]")
    el_all_verify = lambda: (By.XPATH, '(//div[@class="dialog-footer"])[3]//button[2]/span')
    #获取优惠券tips为难添加成功
    GetTipSuccess=lambda :(By.XPATH,"//h2[contains(text(),'添加成功')]")



class PublicCopoun:
    """发布优惠券"""
    # 点击第一个商品发布
    el_PublicCopoun=lambda :(By.CSS_SELECTOR,'tr[class="el-table__row"]:nth-child(1)>td:last-child>div>button')
    # 点击第一个商品发布
    # el_PublicCopoun1 = lambda: (By.XPATH, 'tr[class="el-table__row"]:nth-child(1)>td:last-of-type>div>button')
    # 领取开始时间
    el_StartTime=lambda :(By.XPATH,"(//input[contains(@placeholder,'选择日期时间')])[1]")
    # 选择此时
    el_Selenow=lambda :(By.CSS_SELECTOR,'div[class="el-picker-panel__footer"]>button:nth-child(1)')
    # 领取结束时间
    el_EndTime = lambda: (By.XPATH, "(//input[contains(@placeholder,'选择日期时间')])[2]")
    # 选择2每个月23日
    el_SeleEndTime = lambda: (By.XPATH, '(//tbody//tr[@class="el-date-table__row"])[10]/td[7]')
    el_InputNum=lambda :(By.XPATH,"//input[@type='number']")#发布数量
    # 点击确认
    el_button=lambda :(By.XPATH,'(//div[@class="dialog-footer"])[3]/button[2]')
    # 获取添加成功文案
    GetTipSuccess = lambda: (By.XPATH, "//h2[contains(text(),'添加成功')]")
    # 刷新操作
    el_Refresh=lambda :(By.XPATH,"//span[contains(text(),'刷新')]")
    # 获取第一个优惠券名称
    Get_title=lambda :(By.XPATH,'(//tr[@class="el-table__row"]/td)[3]/div')


if __name__ == '__main__':
    print(Pubelement.el_Product_add())
    print(Spel.el_down_product())
    print(Product_search.el_1_result())
